<?php

namespace App\Http\Middleware;

use App\Services\AdminService\Services\RecordService;
use App\Services\LogServices\LogService;
use Closure;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Route;

class AdminRecode
{
    /**
     * Handle an incoming request.
     *
     * @param  \Illuminate\Http\Request $request
     * @param  \Closure $next
     * @return mixed
     */
    public function handle($request, Closure $next)
    {
        $response = $next($request);
        self::insert($request, $response);
        return $response;

    }


    private function insert($request, $response)
    {
        $id = Auth::id();
        if ($id) {
            RecordService::create($request, $response, $id);
        }
    }

}
